<?php
header('Content-type:text/html;charset=utf8');
/**
 * xysc users Version1.0
 * ==================================
 * Copy 2016-2017
 * Web:www.xjh7.com
 * ==================================
 * Author:xjh
 * Date:2016-3-13
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link rel="stylesheet"  href="<?php echo backweb_CSS_URL;?>index.css" />
<script type="text/javascript" src="<?php echo backweb_JS_URL;?>jquery.js"></script>
<script>

function initPro() {
	 var option1 = '';
		 $.ajax({
			url:'./index.php?r=backweb/brand/search',
			type:'post',
			dataType:'json',
			success:function (jsonData){
				$.each(jsonData, function(index, indexItems) { 
					   option1 += "<option value="+indexItems.category_id+">"
					     + indexItems.name + "</option>";
					  });
				  	$("#cat").append(option1);
				  	$("#cat").bind("change", function() {
				   		selectCity(jsonData);
				  	})
			},     
			error:function (){
				alert("加载失败");
			}
	 });
	  
	 function selectCity(data) {
	  var option2 = '';

	  var selectedIndex = $("#cat :selected").text();
	  $("#bra").empty();
	  if($("#cat :selected").val() == -1){
	   $("#bra").append("<option value='-1' id=\"-1\">请选择品牌</option>");
	  }
		option2 +="<option value=\"-1\">所有品牌</option>";
	  $.each(data, function(index, indexItems) {
	   var proName = indexItems.name;
	   $.each(indexItems.items, function(index, indexItems) {
	    if (indexItems.parentNode != selectedIndex) {
	     return;
	    } else {
	     option2 += "<option  value=" + indexItems.brand_id + ">"
	       + indexItems.name + "</option>";
	    }
	   })
	  });
	  $("#bra").append(option2);
	 };
	};
	$(function() {
	 initPro();
	});
	
	function init(){
		window.fm.submit();
	}
</script>
</head>
<body onload="init();">
	<div class="place">
		<span>位置：</span>
		<ul class="placeul">
			<li><a href="#">首页</a></li>
			<li><a href="#">商品管理</a></li>
			<li><a href="#">商品展示</a></li>
		</ul>
	</div>
        <div>
             <table style="margin-top: 10px">
             <form action="./index.php?r=backweb/goods/goodshow" method="post" name="fm" target="iframe1">
				 <tr>
				 <td class="td_center">搜索分类</td>
				  <td>
					     <select name="cat" class="select" id="cat">
							<option value="-1">所有分类</option>
						</select>
					 </td>
				 <td class="td_center">搜索品牌</td>
				 	<td>
						<select name="brand" class="select"  id="bra">
							<option value="-1">所有品牌</option>
						</select>
				 </td>
				 <td class="td_center">是否可用</td>
					 <td>
						<select name="active" class="select">
							<option value="3">全部</option>
							<option value="1">可用</option>
							<option value="0">不可用</option>
						</select>
					 </td>
					 <td class="td_center">关键字：</td>
					 <td>
					 	<input type="text" name="keyword"  maxlength="120" class="input-text"/>
					 </td>
					  <td >
					 <input type="submit"  name="btquery"  id="btquery" value="查询" class="btn btn82 btn_search" style="margin-left: 20px"/>
					   <input id="useradd" type="button" value="新增" class="btn btn82 btn_add" onclick="location.href='./index.php?r=backweb/goods/toaddgoods'" style="margin-left: 10px" />
					 </td>
				 </tr>
			 </form>
			 </table>
          </div>
          <iframe id="iframe1" name="iframe1" onload="this.height=iframe1.document.body.scrollHeight+20" frameborder="0" marginheight="100" marginwidth="0" width="100%" scrolling="no" ></iframe>
        </div>       
</body>
</html>